﻿using System;
using System.Collections;
using System.Collections.Generic;

using UnityEngine;

namespace HNet
{
    public class MessageProcessing
    {
        private RemoteMethod _remoteMeth = new RemoteMethod();

        public void Distribute(Message msg)
        {
            switch (msg.Type)
            {
                case Message.MsgType.Remote:
                    DistributeRemote(msg);
                    break;

                default:
                    break;
            }
        }

        private void DistributeRemote(Message msg)
        {
            switch (ProtocolBuffer.DeSerialize<string>(msg.Data))
            {
                case RemoteMethod.BytesMethName:
                    _remoteMeth.ExecutionBytesMeth(msg);

                    break;

                default:
                    break;
            }
        }

        public void RegisterBytesMeth(string name, Action<byte[]> meth, object belonger)
        {
            _remoteMeth.RegisterBytesMeth(name, meth, belonger);
        }
    }
}